/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pokergame;

import java.util.ArrayList;
import java.util.Random;

/**
 *
 * @author Justin
 */
public class Deck
{

    private ArrayList<Card> deckOfCards;

    Deck()
    {
        deckOfCards = new ArrayList<Card>();

        // Make deck
        for (Card.Suit suit : Card.Suit.values())
        {
            for (Card.Rank rank : Card.Rank.values())
            {
                deckOfCards.add(new Card(suit, rank));
                deckOfCards.add(new Card(suit, rank));
            }
        }
        shuffle();
    }

    public void shuffle()
    {
        Random generator = new Random();
        int index1, index2;

        // Shuffle deck
        for (int i = 0; i < 26; ++i)
        {
            index1 = generator.nextInt(deckOfCards.size() - 1);
            index2 = generator.nextInt(deckOfCards.size() - 1);

            Card temp = deckOfCards.get(index2);
            deckOfCards.set(index2, deckOfCards.get(index1));
            deckOfCards.set(index1, temp);
        }
    }

    public Card Draw()
    {
        Card toRet = deckOfCards.remove(0);
        deckOfCards.add(toRet);
        return toRet;
    }

    public int CardsLeft()
    {
        return deckOfCards.size() - 1;
    }
}